/*
 * Public by GPL v3
 * Author Tkachenko Vladislav
 */
package plugin;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import system.MessageOUTPUT;

/**
 * Loading System Class
 * @author zem
 */
public class SystemClassLoader {

    SystemInterface instance;
    /**
     * Load System class
     * @param jarname name of system class
     */
    public void Load(String name) {

        File pluginDir = new File("lib");

        File jar = new File("" + pluginDir + File.separatorChar + name+".jar");


        //run plugins

        Class pluginClass = null;


        try {
            URL jarURL = jar.toURI().toURL();
            URLClassLoader classLoader = new URLClassLoader(new URL[]{jarURL});
            //getting main class
           
            boolean mainclass_found = false;
          



            if (mainclass_found) { //if main class has been found
                //start
               
                instance = (SystemInterface) pluginClass.newInstance();
                instance.start();
            } else {
                String[] mes= {name};
                new MessageOUTPUT().OUTPUT("er0007",mes);
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (Exception e) {
            System.out.println(e);
        }

    }

    /**
     * Interrupt System class
     */
    public void Interrupt() {
        try {
            instance.interrupt();
        } catch (Exception er) {
        }
    }
    /**
     * Input some String message to system class
     * @param message The message to input
     */
    public void Input(String message){
    try {
           
        } catch (Exception er) {
        }
    }

   public void Pause() {
    try{


    }catch(Exception er){}

    }
    public void Play() {
    try{
    }catch(Exception er){}

    }
     public void Start (){}
}
